PRG 1.0 TXT

/*
	Color Correction Contrast for Post Process
*/

//-----------------------------------------------------------------------------
// [CONFIG]

include "..\program_include.ocf"

object Program
{
	ubo_data	= array /*UBO*/ {
		{ "inParams",	e_program_data.POSTPROCESS_PARAMS }
	}

	textures	= array /*ProgramTexture*/ {
		{ "unColorMap", e_texture.DIFFUSE }
	}
	
	uniforms	= array /*string*/ {
		"transform", "unTransform."
	}
}


//-----------------------------------------------------------------------------
// [VERTEX]

#version 330 core
#pragma optimize(on)

#define ATTR_POSITION	0
#define ATTR_TEXCOORD	2
#define ATTR_COLOR		1

layout(location = ATTR_POSITION)	in vec3 inPosition;
layout(location = ATTR_TEXCOORD)	in vec2 inTexcoord;


uniform struct Transform {
	mat4	Projection;
} unTransform;


out	TVertexData {
	vec2	vTexcoord;
} Output;


void main(void)
{
	gl_Position  	 = unTransform.Projection * vec4(inPosition, 1.0);
	Output.vTexcoord = inTexcoord;
}


//-----------------------------------------------------------------------------
// [FRAGMENT]

#version 330 core
#pragma optimize(on)

layout(location = 0, index = 0) out vec4	outColor;

uniform sampler2D	unColorMap;


layout (std140)
uniform inParams {
	vec3	vMeanColor  = vec3(0.5, 0.5, 0.5);
	float	fParam		= 0.5;
} unParams;


in	TVertexData {
	vec2	vTexcoord;
} Input;


vec3 ContrastFilter(in vec3 color)
{
	return unParams.vMeanColor + unParams.fParam * ( color - unParams.vMeanColor );
}


void main(void)
{
	vec4	color = texture( unColorMap, Input.vTexcoord );
	outColor = vec4( ContrastFilter( color.rgb ), color.a );
}

// [END]
